package com.wx.cloud.student.controller;

import com.wx.cloud.student.common.CommonResult;
import com.wx.cloud.student.model.Page;
import com.wx.cloud.student.model.TransferTeam;
import com.wx.cloud.student.service.TransferTeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/teamInfo")
public class TransferTeamController {

    @Autowired
    private TransferTeamService transferTeamService;

    @GetMapping("/getSelectList")
    public CommonResult getSelectList(@RequestParam Map<String, Object> data){
        HashMap<String, Object> map = new HashMap<>();
        List<TransferTeam> transferTeams = transferTeamService.getSelectList(data);
        int count = transferTeamService.getSelectCount(data);
        Page page = new Page();
        page.setList(transferTeams);
        page.setTotal(count);
        map.put("list",transferTeams);
        map.put("count",count);
        return CommonResult.success(map);
    }

    @GetMapping("/getTeamInfoById")
    public CommonResult getTeamInfoById(@RequestParam Integer id){
        HashMap<String, Object> map = new HashMap<>();
        TransferTeam transferTeam = transferTeamService.getTeamInfoById(id);
        map.put("data",transferTeam);
        return CommonResult.success(map);
    }

    @PostMapping("/delTeamInfo")
    public CommonResult delTeamInfo(@RequestBody TransferTeam TransferTeam){
        HashMap<String, Integer> map = new HashMap<>();
        int result = transferTeamService.delTeamInfo(TransferTeam);
        map.put("data",result);
        return CommonResult.success(map);
    }

    @PostMapping("/batchDeletion")
    public CommonResult batchDeletion(@RequestParam List<Integer> ids){
        HashMap<String, Object> map = new HashMap<>();
        String result = transferTeamService.batchDeletion(ids);
        map.put("data",result);
        return CommonResult.success(map);
    }

}
